<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<style>
    div{
        width: 500px;
        margin: 200px 800px;
    }
    button{
        width: 120px;
        height: 35px;
        background: tomato;
        border: 0;
        color: white;
    }
    img {
        width: 100px;
        display: none;
    }
</style>
<body>
<div>
    <button>显示</button>
    <img src="../images/erweima.png" alt="">
</div>
<script>
    var btn = document.querySelector('button');
    var img = document.querySelector('img');
    var flag = 0;
    btn.onclick = function () {
        if (flag == 0){
            img.style.display = 'block';
            flag = 1;
        }else {
            img.style.display = 'none';
            flag = 0;
        }
    }
</script>
</body>
</html>